Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase Connection Pool Limit to Avoid Resource Exhaustion #3

Merged
merged 2 commits into from
Sep 8, 2020
Merged

Increase Connection Pool Limit to Avoid Resource Exhaustion #3

merged 2 commits into from
Sep 8, 2020

Conversation

erikgeiser
Copy link
Contributor

@erikgeiser erikgeiser commented Sep 6, 2020

The current HTTP transport limits the idle connections for pooling to 2 (MaxIdleConns is unlimited but MaxIdleConnsPerHost is DefaultMaxIdleConnsPerHost=2) . In the default configuration, monsoon will already do 5 concurrent requests which causes the limit to be exceeded and connections to be closed and reopened unnecessarily.

As this closing and reopening keeps happening over the lifetime of the scan, the operating system will keep the ephemeral ports of the countless closed connections in a TIME_WAIT state for some time. This can then easily cause the system to accumulate ports in this state until it exceeds its limits (on macOS this causes the error can't assign requested address).

This PR sets MaxIdleConnsPerHost and DefaultMaxIdleConnsPerHost to 100. The same solution was already applied to gobuster (see OJ/gobuster#127 and OJ/gobuster#140). The problem is also described in detail in this blog post, which suggests the same solution.

Another solution would be to take the number of "threads" as an argument and set it as the limit. This is what https://github.com/rakyll/hey does.

@erikgeiser erikgeiser changed the title Increase MaxIdleConns(PerHost) Increase Connection Pool Limit to Avoid Ressource Exhaustion Sep 6, 2020
@erikgeiser erikgeiser changed the title Increase Connection Pool Limit to Avoid Ressource Exhaustion Increase Connection Pool Limit to Avoid Resource Exhaustion Sep 6, 2020
Copy link
Member

@rtpt-alexanderneumann rtpt-alexanderneumann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@rtpt-alexanderneumann rtpt-alexanderneumann merged commit 1eadfd1 into RedTeamPentesting:master Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants